<template>
  <div class="account-bottom">
    <div class="bottom-play" @click.stop="playAllMusic">
      <span></span>
      <span>播放全部</span>
    </div>
    <div class="bottom-wrapper">
      <ScrollView >
        <SongList :list='switchNum === 0 ? getFavoriteList : getHistoryList'></SongList>
      </ScrollView>
    </div>
  </div>
</template>

<script>
import SongList from '../SongList.vue'
import ScrollView from '../iscroll.vue'
import { mapGetters, mapActions, mapMutations } from 'vuex'
export default {
  name: 'AccountButtom',
  data () {
    return {
    }
  },
  props: {
    switchNum: {
      type: Number,
      default: 0,
      required: true
    }
  },
  components: {
    ScrollView,
    SongList
  },
  computed: {
    ...mapGetters([
      'getHistoryList',
      'getFavoriteList'
    ])
  },
  methods: {
    ...mapActions([
      'setFullPlayer',
      'setMiniPlayer',
      'setCurrentIndex',
      'getSongs'
    ]),
    ...mapMutations([
      'SONG_TYPE'
    ]),
    playAllMusic () {
      let ids = []
      this.setFullPlayer(true)
      this.setMiniPlayer(false)
      if (this.switchNum === 1) {
        // this.SONG_TYPE(this.getFavoriteList)
        ids = this.getHistoryList.map((value) => {
          return value.id
        })
      } else {
        // this.SONG_TYPE(this.getHistoryList)
        ids = this.getFavoriteList.map((value) => {
          return value.id
        })
      }
      this.setCurrentIndex(0)
      this.getSongs(ids)
    }
  }
}
</script>

<style scoped lang='scss'>
  @import '../../assets/css/variable.scss';
  @import '../../assets/css/mixin.scss';
  .account-bottom{
    position: fixed;
    top: 100px;
    bottom: 0;
    left: 0;
    right: 0;
    .bottom-play{
      width: 260px;
      height: 60px;
      margin: 20px auto;
      display: flex;
      justify-content: center;
      align-items: center;
      border: 1px solid #000;
      border-radius: 30px;
      @include border_color();
      span{
        display: inline-block;
        &:nth-of-type(1){
          width: 46px;
          height: 46px;
          @include bg_img('../../assets/images/small_play');
          margin-right: 20px;
        }
      }
    }
    .bottom-wrapper{
      position: fixed;
      top: 200px;
      left: 0;
      right: 0;
      bottom: 0;
      overflow: hidden;
    }
  }
</style>
